package chapter17;

import java.util.*;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/3/24 15:08
 */
public class ListSortSearch {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>(Arrays.asList("one two three four five".split(" ")));
        list.addAll(Arrays.asList("one two three".split(" ")));
        System.out.println(list);

        Collections.shuffle(list, new Random(47));
        System.out.println("shuffled: " + list);

        ListIterator<String> it = list.listIterator(7);
        while (it.hasNext()) {
            it.next();
            it.remove();
        }

        System.out.println("Trimmed: " + list);

        Collections.sort(list);
        System.out.println("Sorted: " + list);
        String key = list.get(3);
        int index = Collections.binarySearch(list, key);
    }
}
